<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>删除节点</title>
    <script>
        function f1(){
            let u1 = document.getElementById("u1");
            let i3 = document.getElementById("i3");
            u1.removeChild(i3);
        }
        function f2(){
            let u1 = document.getElementById("u1");
            u1.remove();
        }
        function f3(){
            let a1 = document.getElementById("a1");
            a1.onclick = function(){
                // 此处的this表示触发事件的事件源,即:超链接
                console.log(this);
                this.remove();
            }
        }
    </script>
</head>
<body>
<button onclick="f1()">删除u1中指定子节点i3</button>
<button onclick="f2()">删除u1</button>
<button onclick="f3()">赋予事件</button>
<a id="a1" href="javascript:;">删除</a>
<ul id="u1">
    <li>item1</li>
    <li>item2</li>
    <li id="i3">item3</li>
    <li>item4</li>
    <li>item5</li>
</ul>
</body>
</html>